package com.funkids.rabbitmq;

import com.alibaba.fastjson.JSON;
import com.funkids.common.dto.SeckillOrderMq;
import com.funkids.prxis.service.ISysSeckillGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Slf4j
@Service
public class RMReceiver {

    @Autowired
    ISysSeckillGoodsService sysSeckillGoodsService;

    @RabbitListener(queues="queue")
    public void receive(String msg){
        log.info("接收消息："+msg);

        //TODO,秒杀结果
        SeckillOrderMq seckillOrder  = JSON.parseObject(msg, SeckillOrderMq.class);
        sysSeckillGoodsService.seckillDB(seckillOrder.getUserId(),seckillOrder.getGoodsId());

    }


}
